<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<title>门店列表</title>
<link rel="stylesheet" type="text/css" href="/css/reset.css" />
<link rel="stylesheet" type="text/css" href="/css/common.css" />
<link rel="stylesheet" type="text/css" href="/css/thems.css">
<link rel="stylesheet" type="text/css" href="/css/color.css" />
<link rel="stylesheet" type="text/css" href="/css/bootStrap.min.css">
<link rel="stylesheet" type="text/css"
	href="/css/bootstrap-datetimepicker.min.css" />
<script type="text/javascript" src="/js/jquery-3.2.1.js"></script>
<script type="text/javascript " src="/js/bootstrap.js"></script>
<script type="text/javascript " src="/js/bootstrap-datetimepicker.js"
	charset="utf-8"></script>
<script type="text/javascript " src="/js/layer-v3.1.1/layer/layer.js "></script>
<script type="text/javascript">
	$(function() {
		//自适应屏幕宽度
		window.onresize = function() {
			location = location
		};

		var main_h = $(window).height();
		$('.hy_list').css('height', main_h - 45 + 'px');

		var search_w = $(window).width() - 40;
		$('.search').css('width', search_w + 'px');
		//$('.list_hy').css('width',search_w+'px');
	});
</script>
<!--框架高度设置-->
</head>

<body>
	<div id="right_ctn ">
		<div class="right_m ">
			<!--会议列表-->
			<div class="hy_list ">
				<div class="box_t ">
					<span class="name ">型号列表</span>
					<!--当前位置-->
					<div class="position ">
						<span class="glyphicon glyphicon-home "></span> <a href=" ">首页</a>
					</div>
					<!--当前位置-->
				</div>
				<!--查询-->
				<form action="/jump/vehicle" class="navbar-form navbar-left"
					method="post ">
					<div class="input-group ">
						<input type="text " class="form-control storeid" name="carId"
							placeholder="请输入车辆编号" /> <span class="input-group-addon ">
							<span class="glyphicon glyphicon-zoom-in "></span>
						</span>
					</div>
					&nbsp;&nbsp; <select class="form-control value= testselect"
						name="carState">
						<option value="0">请选择车辆状态</option>
						<option value="1">闲置</option>
						<option value="2">已租出</option>
						<option value="3">返程</option>
					</select> &nbsp;&nbsp;&nbsp;&nbsp;

					<div class="input-group">
						<input type="submit" class="btn btn-primary" name="" id=""
							value="查询" />
					</div>
				</form>
				<!--添加 start-->
				
					<ul class="list-inline">
						<li class="margin-top pull-right">
							<button class="btn btn-primary add" data-toggle="modal"
								data-target="#modal-add" data-backdrop="static">
								<span class="glyphicon glyphicon-plus"></span>&nbsp;添加
							</button> <!--添加模态框--> <!--添加模态框-->
						</li>
					</ul>
				
				<!--添加 end-->
				<!--查询-->
				<div class="space_hx ">&nbsp;</div>
				<!--列表-->
				<table class="col-md-11 table table-hover text-center">
					<tr class="bg-hui ">
						<td>编号</td>
						<td>品牌</td>
						<td>型号</td>
						<td>排量</td>
						<td>所属</td>
						<td>所在门店</td>
						<td>车辆状态</td>
						<td>操作</td>
					</tr>
					<#list carList as list>
					<tr>

						<td>${list.carId}</td>
						<td>${list.vehicleBrandName}</td>
						<td>${list.carTypeName}</td>
						<td>${list.carDisplacement}</td> <#if list.belongType==1>
						<td id="${list.belongStoreId}">${list.belongStoreName}</td>
						<#else>
						<td id="${list.belongId}">${list.belongName}</td> </#if>
						<td id="${list.theStoreId}">${list.theStoreName}</td> <#if
						list.carState==1>
						<td id="${list.carState}">闲置</td> </#if> <#if list.carState==2>
						<td id="${list.carState}">租出</td> </#if> <#if list.carState==3>
						<td id="${list.carState}">回程</td> </#if>
						<#if list.carState==4>
						<td id="${list.carState}">维修中</td> </#if>
						<#if list.carState==4>
						<td id="${list.carState}">维修完成</td> </#if>
						<td>
						<div class="btn-group">
							<button type="button" class="btn btn-default dropdown-toggle"
								data-toggle="dropdown" aria-haspopup="true"
								aria-expanded="false">
								设置 <span class="caret"></span>
							</button>
							<ul class="dropdown-menu">
								<li class="update" data-toggle="modal"
								data-target="#mymodal" data-backdrop="static"><a href="#">修改信息</a></li>
								<li><a href="#">申请维修</a></li>
								<li><a href="#">车辆下架</a></li>
								
							</ul>
						</div>
						</td>
					</tr>
					</#list>
				</table>
				<!--列表-->
				<!--右边底部-->
				<div class="r_foot ">
					<div class="r_foot_m ">
						<!--分页-->
						<div class="page ">
							<input type="hidden" id="thisPageNo" />

						</div>
						<!--分页-->
					</div>
				</div>
				</form>
				<!--右边底部-->
			</div>
			<!--会议列表-->
		</div>
	</div>
	<!-- 添加模态框-->
	<div id="modal-add" class="modal fade">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" data-dismiss="modal">&times;</button>
					<!--head-text 标题信息-->
					<h4 class="head-text text-left">添加新车</h4>
				</div>
				<div class="modal-body">
					<form action="" class="form-horizontal addCar" method="post">
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆类型：</span>
							<div class="col-md-6">
								<select class="form-control carType" name="carType">
									<option value="0">请选择车辆类型</option>
									<option value="1">汽车</option>
									<option value="2">货车</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆品牌：</span>
							<div class="col-md-6">
								<select class="form-control carBrandId" name="carBrandId">
									<option value="0">请选择车辆品牌</option> <#list listinfo['veh'] as
									list>
									<option value="${list.vehicleBrandId}">${list.vehicleBrandName}</option>
									</#list>
								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆型号：</span>
							<div class="col-md-6">
								<select class="form-control carTypeId" name="carModelId">
									<option value="0">请选择车辆型号</option>

								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆排量：</span>
							<div class="col-md-6">
								<select class="form-control displacement" name="displacement">
									<option value="0">请选择车辆排量</option>

								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆所属：</span>
							<div class="col-md-6">
								<select class="form-control belongType" name="belongType">
									<option value="0">请选择车辆所属</option>
									<option value="1">门店</option>
									<option value="2">个人</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">所属名称：</span>
							<div class="col-md-6">
								<select class="form-control belongStoreId" name="belongStoreId">
									<option value="0">请选择所属名称</option>
								</select>
							</div>
						</div>

						<div class="form-group">
							<span class="col-md-2 text-center margin-top">限定里程：</span>
							<div class="col-md-6">
								<input type="text" class="form-control" name="limitMileage"
									id="" value="" />
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">生产年份:</span>

							<div class="input-group date form_date col-md-6"
								data-date-format="yyyy MM dd" data-link-format="yyyy-mm-dd">
								<input class="form-control" size="16" type="text"
									name="productionYear" readonly> <span
									class="input-group-addon"><span
									class="glyphicon glyphicon-remove"></span></span> <span
									class="input-group-addon"><span
									class="glyphicon glyphicon-calendar"></span></span>
							</div>
							<input type="hidden" id="dtp_input2" value="" /><br />
						</div>
				</div>
				<div class="modal-footer">
					<button class="btn btn-default" data-dismiss="modal">关闭</button>
					<input type="button" value="保存" class="btn btn-primary addlist" />
				</div>
				</form>
			</div>
		</div>
	</div>
	<!--模态框-->
	<!-- 修改模态框-->
	<div id="mymodal" class="modal fade mymodal">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" data-dismiss="modal">&times;</button>
					<!--head-text 标题信息-->
					<h4 class="head-text text-left">修改信息</h4>
				</div>
				<div class="modal-body">
					<form action="" class="form-horizontal addCar" method="post">
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆类型：</span>
							<div class="col-md-6">
								<select class="form-control carType" name="carType">
									<option value="0">请选择车辆类型</option>
									<option value="1">汽车</option>
									<option value="2">货车</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆品牌：</span>
							<div class="col-md-6">
								<select class="form-control carBrandId" name="carBrandId">
									<option value="0">请选择车辆品牌</option> <#list listinfo['veh'] as
									list>
									<option value="${list.vehicleBrandId}">${list.vehicleBrandName}</option>
									</#list>
								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆型号：</span>
							<div class="col-md-6">
								<select class="form-control carTypeId" name="carModelId">
									<option value="0">请选择车辆型号</option>

								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆排量：</span>
							<div class="col-md-6">
								<select class="form-control displacement" name="displacement">
									<option value="0">请选择车辆排量</option>

								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">车辆所属：</span>
							<div class="col-md-6">
								<select class="form-control belongType" name="belongType">
									<option value="0">请选择车辆所属</option>
									<option value="1">门店</option>
									<option value="2">个人</option>
								</select>
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">所属名称：</span>
							<div class="col-md-6">
								<select class="form-control belongStoreId" name="belongStoreId">
									<option value="0">请选择所属名称</option>
								</select>
							</div>
						</div>

						<div class="form-group">
							<span class="col-md-2 text-center margin-top">限定里程：</span>
							<div class="col-md-6">
								<input type="text" class="form-control" name="limitMileage"
									id="" value="" />
							</div>
						</div>
						<div class="form-group">
							<span class="col-md-2 text-center margin-top">生产年份:</span>

							<div class="input-group date form_date col-md-6"
								data-date-format="yyyy MM dd" data-link-format="yyyy-mm-dd">
								<input class="form-control" size="16" type="text"
									name="productionYear" readonly> <span
									class="input-group-addon"><span
									class="glyphicon glyphicon-remove"></span></span> <span
									class="input-group-addon"><span
									class="glyphicon glyphicon-calendar"></span></span>
							</div>
							<input type="hidden" id="dtp_input2" value="" /><br />
						</div>
				</div>
				<div class="modal-footer">
					<button class="btn btn-default" data-dismiss="modal">关闭</button>
					<input type="button" value="保存" class="btn btn-primary addlist" />
				</div>
				</form>
			</div>
		</div>
	</div>
	<!--模态框-->


	<script type="text/javascript">
		$(function() {
			$('.form_date').datetimepicker({
				format : 'yyyy-mm-dd HH:ii',
				language : 'fr',
				weekStart : 1,
				todayBtn : 1,
				autoclose : 1,
				todayHighlight : 1,
				startView : 2,
				minView : 2,
				forceParse : 0
			});
			$(".carBrandId").on(
					"change",
					function() {
						var brandId = $(this).val();
						$.ajax({
							"url" : "/carType/selByBrandId",
							"type" : "get",
							"data" : {
								"carBrandId" : brandId
							},
							"dataType" : "json",
							success : function(data) {
								$(".carTypeId").html("");
								$(".carTypeId").append(
										"<option value=0>请选择车辆品牌</option>");
								$.each(data, function(i, list) {
									console.log(list.carTypeId);
									$(".carTypeId").append(
											"<option value="+list.carTypeId+">"
													+ list.carTypeName
													+ "</option>")
								})
							},
							error : function(data) {
								window.alert("选择异常");

							}
						})
					});

			$(".carTypeId").on(
					"change",
					function() {
						var carTypeId = $(this).val();
						$.ajax({
							"url" : "/Dis/selByTypeId",
							"type" : "get",
							"data" : {
								"carTypeId" : carTypeId
							},
							"dataType" : "json",
							success : function(data) {
								$(".displacement").html("");
								$(".displacement").append(
										"<option value=0>请选择车辆型号</option>");
								$.each(data, function(i, list) {
									$(".displacement").append(
											"<option value="+list.displacementName+">"
													+ list.displacementName
													+ "</option>")
								})
							},
							error : function(data) {
								window.alert("选择异常");

							}
						})
					})

			$(".belongType").on(
					"change",
					function() {
						var belong = $(this).val();
						if (belong == "1") {
							$(".belongStoreId").attr("name", "belongStoreId")
						} else {
							$(".belongStoreId").removeClass("belongId");
						}
						$.ajax({
							"url" : "/car/selByBelong",
							"type" : "get",
							"data" : {
								"belong" : belong
							},
							"dataType" : "json",
							success : function(data) {
								$(".belongStoreId").html("");
								$(".belongStoreId").append(
										"<option value=0>请选择所属名称</option>");
								$.each(data, function(i, list) {
									if (belong == "1") {
										$(".belongStoreId").append(
												"<option value="+list.storeId+">"
														+ list.storeName
														+ "</option>")
									} else {
										$(".belongStoreId").append(
												"<option value="+list.userId+">"
														+ list.userName
														+ "</option>")
									}
								})
							},
							error : function(data) {
								window.alert("选择异常");

							}
						})
					})

			$(".addlist").click(function() {
				var aa = $(".addCar").serialize();
				$.ajax({
					"url" : "/car/addCar",
					"type" : "get",
					"data" : aa,
					"dataType" : "json",
					success : function(data) {
						if (data != 0) {
							window.alert("添加成功");
							location.href="/jump/vehicle";
						} else {
							window.alert("添加失败");
							location.href="/jump/vehicle";
						}
					},
					error : function() {
						window.alert("添加异常");
						location.href="/jump/vehicle";
					}
				})
			})
		$(".update").click(function(){
			var carId=$(this).parents("tr").find("td").eq(0).html();
			$.ajax({
				"url" : "/car/selBycarId",
				"type" : "get",
				"data" : {"carId":carId},
				"dataType" : "json",
				success : function(data) {
					$("#mymodal").find(".carType option[value="+data.carType+"]").attr("selected",true);
					$("#mymodal").find(".carBrandId option[value="+data.carBrandId+"]").attr("selected",true);
					$("#mymodal").find(".carTypeId option[value="+data.carModelId+"]").attr("selected",true);
					$("#mymodal").find(".displacement option[text="+data.displacement+"]").attr("selected",true);
					$("#mymodal").find(".belongType option[value="+data.carType+"]").attr("selected",true);
					$("#mymodal").find(".belongType option[value="+data.carType+"]").attr("selected",true);
				},
				error : function() {
					alert("加载错误");
				}
			})
		})
		})
	</script>
</body>

</html>